package com.ruoyi.web.controller.ai;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysAppointmentSlot;
import com.ruoyi.system.service.ISysAppointmentSlotService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 医生可预约号源Controller
 * 
 * @author ruoyi
 * @date 2025-06-09
 */
@RestController
@RequestMapping("/system/slot")
public class SysAppointmentSlotController extends BaseController
{
    @Autowired
    private ISysAppointmentSlotService sysAppointmentSlotService;

    /**
     * 查询医生可预约号源列表
     */
    @PreAuthorize("@ss.hasPermi('system:slot:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysAppointmentSlot sysAppointmentSlot)
    {
        startPage();
        List<SysAppointmentSlot> list = sysAppointmentSlotService.selectSysAppointmentSlotList(sysAppointmentSlot);
        return getDataTable(list);
    }

    /**
     * 导出医生可预约号源列表
     */
    @PreAuthorize("@ss.hasPermi('system:slot:export')")
    @Log(title = "医生可预约号源", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysAppointmentSlot sysAppointmentSlot)
    {
        List<SysAppointmentSlot> list = sysAppointmentSlotService.selectSysAppointmentSlotList(sysAppointmentSlot);
        ExcelUtil<SysAppointmentSlot> util = new ExcelUtil<SysAppointmentSlot>(SysAppointmentSlot.class);
        util.exportExcel(response, list, "医生可预约号源数据");
    }

    /**
     * 获取医生可预约号源详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:slot:query')")
    @GetMapping(value = "/{slotId}")
    public AjaxResult getInfo(@PathVariable("slotId") Long slotId)
    {
        return success(sysAppointmentSlotService.selectSysAppointmentSlotBySlotId(slotId));
    }

    /**
     * 新增医生可预约号源
     */
    @PreAuthorize("@ss.hasPermi('system:slot:add')")
    @Log(title = "医生可预约号源", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysAppointmentSlot sysAppointmentSlot)
    {
        return toAjax(sysAppointmentSlotService.insertSysAppointmentSlot(sysAppointmentSlot));
    }

    /**
     * 修改医生可预约号源
     */
    @PreAuthorize("@ss.hasPermi('system:slot:edit')")
    @Log(title = "医生可预约号源", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysAppointmentSlot sysAppointmentSlot)
    {
        return toAjax(sysAppointmentSlotService.updateSysAppointmentSlot(sysAppointmentSlot));
    }

    /**
     * 删除医生可预约号源
     */
    @PreAuthorize("@ss.hasPermi('system:slot:remove')")
    @Log(title = "医生可预约号源", businessType = BusinessType.DELETE)
	@DeleteMapping("/{slotIds}")
    public AjaxResult remove(@PathVariable Long[] slotIds)
    {
        return toAjax(sysAppointmentSlotService.deleteSysAppointmentSlotBySlotIds(slotIds));
    }
}
